export default {
	namespaced: true,
	state: () => ({
		address: JSON.parse(uni.getStorageSync('address') || '{}'),
		token: uni.getStorageSync('token') || '',
		userInfo: JSON.parse(uni.getStorageSync('userInfo') || '{}')
	}),
	mutations: {
		updateAddress(state,address) {
			state.address = address
			this.commit('user/saveAddressToStorage')
		},
		updateUserInfo(state,userInfo) {
			state.userInfo = userInfo
			this.commit('user/saveUserInfoToStorage')
		},
		updateToken(state,token) {
			state.token = token
			this.commit('user/saveTokenToStorage')
		},
		saveAddressToStorage(state) {
			uni.setStorageSync('address',JSON.stringify(state.address))
		},
		saveUserInfoToStorage(state) {
			uni.setStorageSync('userInfo',JSON.stringify(state.userInfo))
		},
		saveTokenToStorage(state) {
			uni.setStorageSync('token',state.token)
		}
	
	},
	getters: {
		detailAddress: state => state.address.provinceName + state.address.cityName + state.address.countyName + state.address.detailInfo
	}
}